﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>流程事件类</title>
     <meta charset="UTF-8"/>
     <title>节点-事件</title>
    <script src="../../Scripts/easyUI/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>

    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet"  type="text/css" />

    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../Comm/Gener.js"></script>

    <script type="text/javascript">
        //页面启动函数.
        $(function () {

            $("#Msg").html("正在加载,请稍后......");


            //初始化groupID.
            var nodeID = GetQueryString("FK_Node");
            var flowNo = GetQueryString("FK_Flow");

            GenerBindEnumKey("DDL_EventDoType", "EventDoType", "0");
            $("#DDL_EventDoType").trigger("change");

            var fk_Event = GetQueryString("FK_Event");


            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_AttrNode");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("ActionDtl_Init");
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            data = JSON.parse(data);

            // 业务单元
            var buess = data["BuessUnits"];
            GenerBindDDL("DDL_Doc", buess, "No", "Name", "");

            var ens = data["FrmEvents"];

            for (var i = 0; i < ens.length; i++) {

                var en = ens[i];

                var newRow = "<tr>";
                newRow = "<tr ><td class=Idx>" + i + "</td>";
                newRow += "<td>" + GetDoType(en.DoType) + "</td>";
                newRow += "<td>" + en.DoDoc + "</td>";
                newRow += "<td>" + en.MsgOK + "</td>";
                newRow += "<td>" + en.MsgError + "</td>";
                newRow += "<td>";
                newRow += "<a href=\"javascript:Delete('" + en.MyPK + "')\"><img src='/WF/Img/Btn/Delete.gif' border=0 />删除</a>";
                newRow += "</td>";
                newRow += "</tr>";

                $("#Table1 tr:last").after(newRow);
            }

            //  document.getElementById('Table1').caption = "事件类:" + nodeID;

            //事件类型.
            //var eventLists = data["EventLists"];

        });

        function GetDoType(doType) {

            var cfg = "@0=禁用@1=执行存储过程@2=执行SQL语句@3=执行URL@4=WebServices(未完成)@5=执行ddl文件的类与方法@6=EventBase类@7=业务单元";

            var cfgs = cfg.split('@');

            for (var i = 0; i < cfgs.length; i++) {
                var vss = cfgs[i];
                if (vss.indexOf('=') == -1)
                    continue;

                var vals = vss.split('=');

                if (vals[0] == doType)
                    return vals[1];
            }

            return doType+'ss';
        }

        function Save() {


            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_AttrNode");
            handler.AddUrlData();
            handler.AddFormData();
            var data = handler.DoMethodReturnString("ActionDtl_Save");
            if (data.indexOf('err@') >= 0) {
                alert(data);
                return;
            }
            alert(data);

            window.location.href = window.location.href;
            return;
        }

        function Delete(mypk) {

            if (confirm('您确定要删除吗？') == false)
                return;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_AttrNode");
            handler.AddUrlData();
            handler.AddFormData();
            handler.AddPara("MyPK", mypk);

            var data = handler.DoMethodReturnString("ActionDtl_Delete");

            if (data.indexOf('err@') >= 0) {
                alert(data);
                return;
            }

            alert(data);

            window.location.href = window.location.href;
            return;
        }
		function doChangeContent(o) {
			if ($(o).val() == "7") {
				$("#TB_Doc").hide();
				$("#DDL_Doc").show();
			} else {
				$("#TB_Doc").show();
				$("#DDL_Doc").hide();
			}
		}
    </script>
</head>
<body>
<form id="cc">
<table style="width:90%;" id="Table1" >
<caption>设置的事件列表</caption>
<tr>
<th>IDX</th>
<th>类型</th>
<th>内容</th>
<th>成功提示</th>
<th>失败提示</th>
<th>操作</th>
</tr>
</table>

<table style="width:80%;" id="Table2">
<caption> 新增事件 </caption>
<tr>
<td>内容类型</td>
<td><select id="DDL_EventDoType" name="DDL_EventDoType" onchange="doChangeContent(this)"></select></td>
</tr>

<tr>
<td>内容</td>
<td>

<textarea id="TB_Doc" name="TB_Doc" style="display: none;"></textarea>	<!-- 其它事件 -->

<select id="DDL_Doc" name="DDL_Doc" style="display: none;"></select>	<!-- 业务单元 -->

</td>
</tr>

<tr>
<td colspan=1>
执行成功信息提示(可为空)
</td>
<td colspan=1>
 <input type=text  id="MsgOK" name="MsgOK" />
</td>
</tr>

<tr>
<td colspan=1>
执行失败时提示(可为空)
</td>

<td>
 <input type=text  id="MsgError"  name="MsgError" />
</td>
</tr>
</table>

<input id="Btn_Save"  name="Btn_Save" value="保存" onclick="Save();"  type="button"  />


</form>

</body>
</html>
